package string;

public class MatchesDemo {
    public static void main(String[] args) {
        /*
        邮箱的正则表达式:
        [a-zA-Z0-9_]+@[a-zA-Z0-9}+(\.[a-zA-Z}+)+
         */
        String email = "123456@qq.com";
        String email2 = "123456*@qq.com";
        String regex = "[a-zA-Z0-9_]+@[a-zA-Z0-9]+(\\.[a-zA-Z]+)+";
        boolean b = email.matches(regex);
        if(b){
            System.out.println("邮箱格式正确");
        }else{
            System.out.println("邮箱格式错误");
        }
        boolean c = email2.matches(regex);
        if(c){
            System.out.println("邮箱格式正确");
        }else{
            System.out.println("邮箱格式错误");
        }
    }
}